package cn.gailvlun.gll.mgr;

import android.content.Context;

import com.umeng.analytics.MobclickAgent;

import java.util.concurrent.TimeUnit;

import cn.gailvlun.gll.chatlib.ChatClient2;
import cn.gailvlun.gll.chatlib.db.ChatDB2;
import cn.gailvlun.gll.net.HttpMethods;
import cn.gailvlun.gll.presentation.login.LoginActivity;
import cn.gailvlun.gll.util.ProfileUtil;
import cn.gailvlun.gll.util.RxUtil;
import io.reactivex.functions.Consumer;



public class ShortcutMgr {
    public static void logOut(Context context) {
        MobclickAgent.onProfileSignOff();

        RxUtil.timer(100, TimeUnit.MILLISECONDS)
                .subscribe(new Consumer<Long>() {
                    @Override
                    public void accept(Long aLong) throws Exception {
                        ProfileUtil.logOut();
                    }
                });
        ChatDB2.INSTANCE.logout();
        ChatClient2.getInstance().disconnect();
        HttpMethods.logOut();
        LoginActivity.openActivity(context, true);
    }
}
